[HEADER]
	VERSION		01.00.00.00
	DESCRIPTION Texture Example
	COPYRIGHT	Imagination Technologies Ltd
[/HEADER]

[TEXTURES] 
	FILE leaf 	leaf.pvr		LINEAR-LINEAR-NEAREST
	FILE marble maskmain.pvr   	LINEAR-LINEAR-NEAREST
[/TEXTURES]

[VERTEXSHADER]
	NAME 		MyVertexShader

	// LOAD GLSL AS CODE
	[GLSL_CODE]
		attribute highp vec4	myVertex;
		attribute mediump vec3	myNormal;
		attribute mediump vec2	myUVMain;
		attribute mediump vec2	myUVDetail;

		uniform mediump mat4	myWVPMatrix;
		uniform mediump mat3	myWorldViewIT;
		uniform mediump vec3	myLightPos;

		varying mediump float	DiffuseIntensity;
		varying mediump vec2	texCoordinateMain;
		varying mediump vec2	texCoordinateDetail;
		varying mediump vec2	varEnvMap;

		void main(void)
		{
			gl_Position = myWVPMatrix * myVertex;
			mediump vec3 transNormal = normalize(myWorldViewIT * myNormal);
			
			vec3 LightDirection = myLightPos -  myVertex.xyz;
			DiffuseIntensity = 0.5 + dot(transNormal, normalize(LightDirection)) * 0.5;
			texCoordinateMain	= myUVMain.st;
			texCoordinateDetail	= myUVDetail.st;
			varEnvMap = 0.5 + transNormal.xy * 0.5;
		}
	[/GLSL_CODE]
[/VERTEXSHADER]
    
[FRAGMENTSHADER] 
	NAME 		MyFragmentShader 

	// LOAD GLSL AS CODE
	[GLSL_CODE]
		uniform sampler2D sampler2d;
		uniform sampler2D envmap2d;
		varying lowp float	DiffuseIntensity;
		varying highp vec2	texCoordinateMain;
		varying highp vec2	texCoordinateDetail;
		varying highp vec2	varEnvMap;

		void main (void)
		{
			lowp vec4 envColour = 0.5 * texture2D(envmap2d, varEnvMap);
			gl_FragColor = texture2D(sampler2d, texCoordinateMain) * texture2D(sampler2d, texCoordinateDetail) * (DiffuseIntensity + envColour);
		}
	[/GLSL_CODE]
[/FRAGMENTSHADER]
 
[EFFECT] 
	NAME 	ReflectionEffect

	UNIFORM myWorldViewIT 		WORLDVIEWIT
	UNIFORM myWVPMatrix 		WORLDVIEWPROJECTION
	UNIFORM	myLightPos			LIGHTPOSMODEL0
	UNIFORM	sampler2d			TEXTURE0
	UNIFORM	envmap2d			TEXTURE1
	
	ATTRIBUTE myVertex			POSITION
	ATTRIBUTE myNormal			NORMAL
	ATTRIBUTE myUVMain			UV0
	ATTRIBUTE myUVDetail		UV1

   	VERTEXSHADER MyVertexShader
   	FRAGMENTSHADER MyFragmentShader
   	
	TEXTURE 0 marble
	TEXTURE 1 leaf
[/EFFECT]
